package com.Day14;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * @author: 若若叶
 * @date: 2021/8/8 9:53
 * FileName: Test
 * Description:
 */
public class Test {
    public static void main(String[] args) {
        //初始化
        Class userregiste = null;
        {
            try {
                //获取类
                userregiste = Class.forName("com.Day14.Registe");
                //创建对象
                Object o = userregiste.newInstance();
                //根据方法名，参数，获取方法
                Method registe = userregiste.getDeclaredMethod
                        ("registe", String.class, String.class);
                //调用方法
                Object invoke = registe.invoke(o, "admin", "admin");
                System.out.println(invoke);
            } catch (ClassNotFoundException e) {
                System.out.println(e.getMessage());
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (NoSuchMethodException e) {
                e.printStackTrace();
            } catch (InvocationTargetException e) {
                e.printStackTrace();
            }
        }


    }
}
